<template>
    <div>
        <Select v-model="value"
                filterable
                :multiple="multiple">
            <Option v-for="item in dataList"
                    :value="item.value"
                    :key="item.value">{{ item.label }}</Option>
        </Select>
    </div>
</template>
<script>
    import { GetShopSelect } from '@/api/components';
    export default {
        name: 'selectInput',
        props: {
            multiple: {
                type: Boolean,
                default: true
            },
            modelDate: {
                type: [String, Array]
            }
        },
        data () {
            return {
                dataList: [],
                value: []
            };
        },
        created () {
            this.getShopNameSelect();
            if (this.multiple) {
                let value = [...this.modelDate];
                this.value = value;
            } else {
                this.value = this.modelDate + '';
            }
        },
        methods: {
            getShopNameSelect () {
                let data = {};
                // 开始请求商品列表
                GetShopSelect(data).then(res => {
                    this.dataList = [...res.list];
                });
            },
            // 改变选中值
            selectChange (value) {
                this.$emit('changeSelectInputModel', value);
            }
        }
    }
</script>
<style lang="less">
</style>
